import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const router = new VueRouter({
  routes: [
    {
      path: '/login',
      name: 'login',
      component: () => import('@/views/login'),
    },
    {
      path: '/',
      component: () => import('@/views/Layout'),
      redirect: 'home',
      children: [
        {
          path: 'home',
          component: () => import('@/views/home'),
        },
        {
          path: 'video',
          component: () => import('@/views/video'),
        },
        {
          path: 'profile',
          component: () => import('@/views/profile'),
        },
        {
          path: 'qa',
          component: () => import('@/views/qa'),
        },
      ],
    },
    {
      path: `/detail/:id`,
      component: () => import('@/views/detail'),
      props: true,
    },
  ],
})

export default router
// 路由前置守卫
router.beforeEach((to, from, next) => {
  next()
  // console.log(to, from)
})
